<include file="Public/header"/>
<div class="row">
    <div class="col-md-12">
        <form class="layui-form" id="editForm">
            <div class="layui-form-item">
                <label class="layui-form-label">菜单图标</label>
                <div class="layui-input-inline">
                    <input type="text" name="menuicon" value="<{$menu_info.icon}>" placeholder="请输入菜单图标"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">具体参考layui官网</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">菜单名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="menuname" lay-verify="required" value="<{$menu_info.title}>"
                           placeholder="请输入菜单名称"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">控制器名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="controller" value="<{$opt[0]}>"
                    <if condition="$menu_info['pid']">lay-verify="required"</if>
                    placeholder="请输入控制器名称" autocomplete="off" class="layui-input">
                </div>

                <div class="layui-form-mid layui-word-aux">驼峰法命名</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">方法名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="action" value="<{$opt[1]}>"
                    <if condition="$menu_info['pid']">lay-verify="required"</if>
                    placeholder="请输入方法名称" autocomplete="off" class="layui-input">

                </div>
                <div class="layui-form-mid layui-word-aux">驼峰法命名</div>
            </div>
            <input type="hidden" name="id" value="<{$menu_info.id}>">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="editmenu">立即提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
<include file="Public/footer"/>
<script>
    layui.use('form', function () {
        var form = layui.form,
            $ = layui.jquery;

        //监听提交
        form.on('submit(editmenu)', function(data){
            $.ajax({
                url:"<{:U('Menu/editMenu')}>",
                type:"post",
                data:$('#editForm').serialize(),
                success:function(res){
                    if(res.status){
                        layer.alert("操作成功", {icon: 6},function () {
                            parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }else{
                        layer.msg(res.msg ? res.msg : "操作失败!", {icon: 5},function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                        return false;
                    }
                }
            });
            return false;
        });

    });
</script>
</body>
</html>